<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>
			3：输入一个正整数，获得他的最高位，比如123的最高位是1，10000的最高位是1
			，9的最高位是9。。。</title>
		<script type="text/javascript">
			function top1() {
				var a = document.getElementById("num").value;
				var b;
				while (a > 10) {
					a = a / 10;
				}
				if (a == 10) {
					b = 1;
				} else {
					b = a % 10;
					b = parseInt(b);	
					}
					document.getElementById("result").value = b;
				}
		</script>
	</head>
	<body>
		<div>
			<input type="number" name="nu" id="num" placeholder="请输入数字">
			<button onclick="top1()">转换</button><input type="text" name="rs" id="result">
		</div>
	</body>
</html>
